﻿using UnityEngine;

namespace Com.ZX
{
	public abstract class MbSingleton<T> : MonoBehaviour where T : MonoBehaviour
	{
		protected static T _Instance;
		public static T inst
		{
			get
			{
				if (_Instance == null)
				{
					GameObject obj = GameObject.Find("GlobalGameObject");
					if (obj == null)
					{
						obj = new GameObject("GlobalGameObject");
						obj.AddComponent<T>();
						DontDestroyOnLoad(obj);
					}
					_Instance = obj.GetComponent<T>();
				}
				return _Instance;
			}
		}
	}
}

